package com.xio.cloud.service.impl;

import cn.hutool.core.util.IdUtil;
import com.xio.cloud.service.IMessageProvider;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.stream.annotation.EnableBinding;
import org.springframework.cloud.stream.messaging.Source;
import org.springframework.messaging.MessageChannel;
import org.springframework.messaging.support.MessageBuilder;

import javax.annotation.Resource;


/**
 * @Author: xio
 * @Description: 实现类
 * @Date: 2020/10/13 16:52
 */
@EnableBinding(Source.class)
@Slf4j
public class MessageProvider implements IMessageProvider {

    @Resource
    private MessageChannel output;

    @Override
    public String send() {
        String uuid = IdUtil.simpleUUID();
        output.send(MessageBuilder.withPayload(uuid).build());
        log.info("- - - - - uuid:" + uuid );
        return uuid;
    }
}
